int DZturnoffpreproc(CPXENVptr env){
   int status = 0;

  /* Turn on or off preprocessor and presolve for the nodes */
   status = CPXsetintparam(env, CPX_PARAM_PREIND, CPX_OFF);       // presolve 
   if ( status )  return status;
   status = CPXsetintparam(env, CPX_PARAM_PRESLVND, CPX_OFF);     // presolve at the node
   if ( status )  return status;
   status = CPXsetintparam(env, CPX_PARAM_RELAXPREIND, CPX_OFF);  // presolve of relaxed lp at the root node  
   if ( status )  return status;
   status = CPXsetintparam(env, CPX_PARAM_COEREDIND, CPX_OFF);   // coefficient reduction
   if ( status )  return status;
   status = CPXsetintparam(env, CPX_PARAM_AGGIND, CPX_OFF);      // aggregator
   if ( status )  return status;

   /* Assure linear mappings between the presolved and original
      models */
   status = CPXsetintparam (env, CPX_PARAM_PRELINEAR, 0);
   if ( status )  return status;

   /* Let MIP callbacks work on the original model */
   CPXsetintparam(env, CPX_PARAM_MIPCBREDLP, CPX_OFF);
   if ( status )  return status;

   return 0;
}

int DZturnoffcuts(CPXENVptr env){
  int status = 0;
   /* Set cut options */
   status = CPXsetintparam(env,CPX_PARAM_CLIQUES , -1);	    if ( status )  return status;
   status = CPXsetintparam(env,CPX_PARAM_COVERS , -1);	    if ( status )  return status;
   status = CPXsetintparam(env,CPX_PARAM_DISJCUTS , -1);	    if ( status )  return status;
   status = CPXsetintparam(env,CPX_PARAM_FLOWPATHS , -1);    if ( status )  return status;
   status = CPXsetintparam(env,CPX_PARAM_GUBCOVERS , -1);    if ( status )  return status;
   status = CPXsetintparam(env,CPX_PARAM_FRACCUTS , -1);	    if ( status )  return status;
   status = CPXsetintparam(env,CPX_PARAM_IMPLBD , -1);       if ( status )  return status;
   status = CPXsetintparam(env,CPX_PARAM_FLOWCOVERS , -1);   if ( status )  return status;
   status = CPXsetintparam(env, CPX_PARAM_MIRCUTS , -1 );    if ( status )  return status;
   status = CPXsetintparam(env, CPX_PARAM_ZEROHALFCUTS ,-1 );   if ( status ) return status;
   return 0;
}

int DZsetmipstrategy(CPXENVptr env){

  int status;
   /* Select the root algorithm */
   status = CPXsetintparam (env, CPX_PARAM_STARTALG,CPX_ALG_AUTOMATIC);
   if ( status )  return status;

   /* Set controlling strategies */
   status = CPXsetintparam(env, CPX_PARAM_MIPEMPHASIS, 0);	 //3 to emphasize the best bound
   if ( status )  return status;
   status = CPXsetintparam(env, CPX_PARAM_NODESEL, 1); //or 2
   if ( status )  return status;
   status = CPXsetintparam(env, CPX_PARAM_VARSEL, 0); //0[Auto]
   if ( status )  return status;
   status = CPXsetintparam(env, CPX_PARAM_BRDIR, 0); //-1[Downward] 0[Auto] 1[Upward]
   if ( status )  return status;
   status = CPXsetintparam(env, CPX_PARAM_PROBE, -1);
   if ( status )  return status;
   status = CPXsetintparam(env, CPX_PARAM_ADVIND, 1);  //Need to be turned off otherwise it will cause trouble for the next iteration
   if ( status )  return status;
   /* Set heuristic strategy */
   status = CPXsetintparam(env, CPX_PARAM_HEURFREQ , -1 );    //-1 to turn it off
   if ( status )  return status;
   //   status = CPXsetintparam(env, CPX_PARAM_BBINTERVAL , 0);   
   //   if ( status )  return status;
   //   CPXsetintparam(env, CPX_PARAM_FPHEUR , -1 );    
   //   CPXsetintparam(env, CPX_PARAM_LBHEUR , 1 );    

   /* Turn on traditional search for user with control callbacks */
   //   status = CPXsetintparam (env, CPX_PARAM_MIPSEARCH, CPX_MIPSEARCH_TRADITIONAL);
   //   if ( status )  return status;

   /* Set parallel mode and threads */
   CPXsetintparam(env,CPX_PARAM_PARALLELMODE, CPX_PARALLEL_DETERMINISTIC);
   if ( status )  return status;
   CPXsetintparam(env,CPX_PARAM_THREADS, 1);
   if ( status )  return status;

   return 0;

}

int  DZsetmiplimits  (CPXENVptr env){
  int status = 0;
/* Set terminating criterion*/
     CPXsetdblparam(env, CPX_PARAM_EPGAP, 0.00000 );   
     CPXsetdblparam(env, CPX_PARAM_EPAGAP, 0.00000 );   
     CPXsetintparam(env, CPX_PARAM_INTSOLLIM, 1000000000); 
  //   if ( status )  return status;
  //   CPXsetintparam(env, CPX_PARAM_NODELIM, 10000000); 
  //   if ( status )  return status;
   //   CPXsetdblparam(env,  CPX_PARAM_TILIM, 3600);    
   CPXsetintparam(env,  CPX_PARAM_CLOCKTYPE, 1); 
   // CPXsetintparam(env,CPX_PARAM_MIPSTART, 0); 
   return status;
}


int DZsetmipoutput (CPXENVptr env, char *logbuffer){
  int status = 0;

  /* Turn on output to the screen */
   status = CPXsetintparam (env, CPX_PARAM_SCRIND, CPX_OFF);
   if ( status ) {
      fprintf (stderr, 
               "Failure to turn on screen indicator, error %d.\n", status);
      return status;
   }

   /* Set output options */
   status = CPXsetintparam(env,CPX_PARAM_MIPINTERVAL , 50);
   if ( status )  return status;
   status = CPXsetintparam(env,CPX_PARAM_MIPDISPLAY , 2);
   if ( status )  return status;

   return status;
}



int DZgetmipprobsize(CPXENVptr env,CPXLPptr lp, int *nRowsPtr, int *nColsPtr, int *nBinsPtr){

  int status = 0;
  *nRowsPtr = CPXgetnumrows (env, lp);
  *nColsPtr = CPXgetnumcols (env, lp);
  *nBinsPtr = CPXgetnumbin(env, lp);
  //   printf("Num rows and colums: %d %d \n",nRows, nCols);
  //   printf("Number of binary variables are: %d \n", nBins);

  return status;
}

int DZgetbigmindex(CPXENVptr env, CPXLPptr lp, int ni, int nj, 
		  int **bigmRowIdx, int **bigmColIdx) {
  int status = 0;
  int i,j,k, fixc;
  char tempColName[10];
  char tempRowName[10];
  double coef;

  fixc = (nloc+1)*nclt;

  for(i = 0; i<ni; i++){
     for(j = 0; j<nj; j++){
       sprintf(tempRowName, "c%d", i+2);
       sprintf(tempColName, "b%d", fixc+i+1);

       CPXgetrowindex(env,lp,tempRowName, &bigmRowIdx[i][j]);
       CPXgetcolindex(env,lp,tempColName, &bigmColIdx[i][j]);
   
       status = CPXgetcoef(env, lp, bigmRowIdx[i][j], bigmColIdx[i][j], &coef);
       if(coef != -1){
	 fprintf (stderr, "Big M checking faied.\n");
	 return 1;
       }
     }
   }
   printf("All the coordinates of big M are checked!\n");
   return status;
}
